<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/23/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/23/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/25/%E6%A0%91%E8%8E%93%E6%B4%BE4b%E4%B8%8A%E4%BD%BF%E7%94%A8mcp2515/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/25/%E6%A0%91%E8%8E%93%E6%B4%BE4b%E4%B8%8A%E4%BD%BF%E7%94%A8mcp2515/" class="post-title-link" itemprop="url">树莓派4b上使用mcp2515</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-25 16:04:03" itemprop="dateCreated datePublished" datetime="2021-05-25T16:04:03+08:00">2021-05-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/05/25/%E6%A0%91%E8%8E%93%E6%B4%BE4b%E4%B8%8A%E4%BD%BF%E7%94%A8mcp2515/" class="post-meta-item leancloud_visitors" data-flag-title="树莓派4b上使用mcp2515" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/25/%E6%A0%91%E8%8E%93%E6%B4%BE4b%E4%B8%8A%E4%BD%BF%E7%94%A8mcp2515/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/25/%E6%A0%91%E8%8E%93%E6%B4%BE4b%E4%B8%8A%E4%BD%BF%E7%94%A8mcp2515/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    使用的mcp2515模块是某宝上最常见的那种：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210524155921.png" style="zoom:70%;">

<p>​    另外树莓派上的引脚图如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210524160501.png" style="zoom:57%;">

<p>​    树莓派与MCP2515模块的连接方式为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">PIN Pi  ----------------&gt; MCP2515 </span><br><span class="line">#02 5V -----------------&gt; VCC</span><br><span class="line">#06 GND ----------------&gt; GND</span><br><span class="line">#24 (SPI_CE0)GPIO08 ----&gt; CS</span><br><span class="line">#21 (SPI_MISO)GPIO09 ---&gt; SO</span><br><span class="line">#19 (SPI_MOSI)GPIO10 ---&gt; SI</span><br><span class="line">#23 (SPI_CLK)GPIO11 ----&gt; SCK</span><br><span class="line">#22 (GPIO_GEN6)GPIO25 --&gt; INT</span><br></pre></td></tr></table></figure>
<ol>
<li>打开树莓派SPI功能，可以通过编辑**/boot/config.txt**文件来实现：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vi /boot/config.txt</span><br></pre></td></tr></table></figure>
<p>​    在config.txt文件中找到<strong>dtparam=spi=on</strong>，把它前面的#号去掉，也就是取消这一行的注释。然后在下面新起一行，加入下面的语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25 dtoverlay=spi-bcm2835</span><br></pre></td></tr></table></figure>
<p>这一步做完以后，config.txt文件可能看起来是这样的:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210524161046.png" style="zoom:67%;">

<p>​    2.安装CAN tools：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install can-utils</span><br></pre></td></tr></table></figure>
<p>​    3.查看spi设备，是否有CAN接口</p>
<p>​    记得先重启树莓派</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ls /sys/bus/spi/devices/spi0.0/net/ </span><br><span class="line">can0</span><br></pre></td></tr></table></figure>
<p>如果在/net/目录下有can0这个文件夹，那就说明你的CAN的收发功能能够正常使用</p>
<p>​    4.设置CAN通信接口</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">sudo ip link set can0 up type can bitrate 500000 loopback on</span><br><span class="line"></span><br><span class="line">bitrate 500000：比特率设置为500k,在这里比特率是波特率的两倍，所以波特率为250k</span><br><span class="line">loopback on : 将MCP2515的工作模式设置为环回模式</span><br></pre></td></tr></table></figure>
<p>​    成功后可以通过<code>ifconfig can</code>查看can0信息：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210524161739.png" style="zoom:67%;">

<ol start="5">
<li><p>测试一个发送，一个接收</p>
<p>打开两个terminal窗口，分别执行下面的指令：</p>
</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cansend can0 123#AABBCCDDEEFF</span><br><span class="line"></span><br><span class="line">candump can0   (这条指令先执行)</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/16/Jetson%20Nano%E9%80%9A%E8%BF%87%E7%AC%94%E8%AE%B0%E6%9C%AC%E5%AE%9E%E7%8E%B0%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/16/Jetson%20Nano%E9%80%9A%E8%BF%87%E7%AC%94%E8%AE%B0%E6%9C%AC%E5%AE%9E%E7%8E%B0%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5/" class="post-title-link" itemprop="url">Jetson Nano通过笔记本实现网络连接</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-16 13:49:22" itemprop="dateCreated datePublished" datetime="2021-05-16T13:49:22+08:00">2021-05-16</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/05/16/Jetson%20Nano%E9%80%9A%E8%BF%87%E7%AC%94%E8%AE%B0%E6%9C%AC%E5%AE%9E%E7%8E%B0%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson Nano通过笔记本实现网络连接" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/16/Jetson%20Nano%E9%80%9A%E8%BF%87%E7%AC%94%E8%AE%B0%E6%9C%AC%E5%AE%9E%E7%8E%B0%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/16/Jetson%20Nano%E9%80%9A%E8%BF%87%E7%AC%94%E8%AE%B0%E6%9C%AC%E5%AE%9E%E7%8E%B0%E7%BD%91%E7%BB%9C%E8%BF%9E%E6%8E%A5/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    本文来自于网络，原地址：<a target="_blank" rel="noopener" href="https://bbs.huaweicloud.com/blogs/249826">https://bbs.huaweicloud.com/blogs/249826</a></p>
<h2 id="1-无线WLAN设置"><a href="#1-无线WLAN设置" class="headerlink" title="1. 无线WLAN设置"></a>1. 无线WLAN设置</h2><p>​    笔记本电脑连上WIFI后，打开“网络和Internet”， 属性 ，勾选Internet连接共享，确定。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210516132857.png" style="zoom:60%;">

<h2 id="2-有线网卡设置"><a href="#2-有线网卡设置" class="headerlink" title="2. 有线网卡设置"></a>2. 有线网卡设置</h2><p>​    选择连接开发板的有限网卡 属性 —— 修改IPV4 —— 确定，我打开的时候就是下图这个样子了，我这边也不需要做其他什么修改。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210516133019.png" style="zoom:70%;">

<h2 id="3-nano上设置"><a href="#3-nano上设置" class="headerlink" title="3. nano上设置"></a>3. nano上设置</h2><h3 id="3-1"><a href="#3-1" class="headerlink" title="3.1"></a>3.1</h3><p>​    输入命令：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo gedit /etc/network/interfaces</span><br></pre></td></tr></table></figure>
<p>​    编辑/etc/network/interfaces文件，假设原始状态下网卡为eth0，在文件中添加以下内容：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">inet eth0 iface <span class="keyword">static</span></span><br><span class="line">address <span class="number">192.168</span><span class="number">.137</span><span class="number">.2</span></span><br><span class="line">gateway <span class="number">192.168</span><span class="number">.137</span><span class="number">.1</span></span><br><span class="line">netmask <span class="number">255.255</span><span class="number">.255</span><span class="number">.0</span></span><br></pre></td></tr></table></figure>
<p>​    保存文件并退出。</p>
<h3 id="3-2"><a href="#3-2" class="headerlink" title="3.2"></a>3.2</h3><p>​    在终端上输入以下命令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gedit &#x2F;etc&#x2F;reslov.conf</span><br></pre></td></tr></table></figure>
<p>​    编辑/etc/reslov.conf文件，在文件中添加以下内容：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nameserver  192.168.137.1</span><br></pre></td></tr></table></figure>
<p>​    保存文件并退出，就可以实现网络共享了。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/12/MM32F103%E4%B8%8A%E5%88%86%E6%9E%90usb%E7%9A%84%E6%9E%9A%E4%B8%BE%E8%BF%87%E7%A8%8B%E4%B8%80/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/12/MM32F103%E4%B8%8A%E5%88%86%E6%9E%90usb%E7%9A%84%E6%9E%9A%E4%B8%BE%E8%BF%87%E7%A8%8B%E4%B8%80/" class="post-title-link" itemprop="url">MM32F103上分析usb的枚举过程一</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-12 14:44:14" itemprop="dateCreated datePublished" datetime="2021-05-12T14:44:14+08:00">2021-05-12</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/05/12/MM32F103%E4%B8%8A%E5%88%86%E6%9E%90usb%E7%9A%84%E6%9E%9A%E4%B8%BE%E8%BF%87%E7%A8%8B%E4%B8%80/" class="post-meta-item leancloud_visitors" data-flag-title="MM32F103上分析usb的枚举过程一" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/12/MM32F103%E4%B8%8A%E5%88%86%E6%9E%90usb%E7%9A%84%E6%9E%9A%E4%B8%BE%E8%BF%87%E7%A8%8B%E4%B8%80/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/12/MM32F103%E4%B8%8A%E5%88%86%E6%9E%90usb%E7%9A%84%E6%9E%9A%E4%B8%BE%E8%BF%87%E7%A8%8B%E4%B8%80/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    这里开始分析枚举过程的第一个来回，文章中会具体分析MM32F103相关的USB寄存器含义以及代码，从而更加直观的理解这个过程。</p>
<p>​    枚举过程的第一个来回会发起第一个控制传输：</p>
<ul>
<li>建立过程：主机 SETUP 包（发往地址 0 端点 0 ），主机数据包（请求设备描述符），设备握手包ACK。</li>
<li>数据过程：主机先发一个 IN 令牌包，设备发一个数据包，主机发 ACK 包。</li>
<li>状态过程：主机发 OUT 包（通知设备要输出）、主机发 0 字节状态数据包（这个是 0字节，表明自己收到设备描述符）、设备发握手 ACK 包。</li>
</ul>
<h2 id="1-建立过程"><a href="#1-建立过程" class="headerlink" title="1.建立过程"></a>1.建立过程</h2><p>​    即一个setup事务。<strong>看到事务这两个字，肯定要一下子想到它包含令牌包Token packet、数据包Data packet、握手包Handshack packet</strong>。</p>
<p>​    所以这个setup事务包含有：主机 SETUP 包（发往地址0端点0）、主机数据包（请求设备描述符）、设备握手包ACK 。</p>
<h3 id="1-1-setup事务的setup包"><a href="#1-1-setup事务的setup包" class="headerlink" title="1.1 setup事务的setup包"></a>1.1 setup事务的setup包</h3><p>​    这边主机先发送一个setup包，那么mm32这边会产生一个中断，mm32有一个USB端点0中断状态寄存器(EP0_INT_STATE)</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210427104212.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210427104326.png" style="zoom:67%;">

<p>(补充：上面寄存器的说明感觉说的不是特别好，容易引起歧义。更准确的说法我觉得应该是：<strong>置位后可以从寄存器SETUP0~7读取setup事务的数据包内容</strong>)</p>
<p>程序会进入接收到setup包这个中断，如下图所示：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20210427111337.png"></p>
<h3 id="1-2-setup事务的数据包"><a href="#1-2-setup事务的数据包" class="headerlink" title="1.2 setup事务的数据包"></a>1.2 setup事务的数据包</h3><p>​    数据包是主机发送的，用来请求设备的描述符，目的就是告诉设备：我想知道你的设备描述符，这样在后面的数据过程设备就知道要告诉主机什么信息了。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">usb_setup_handle</span><span class="params">( <span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    uint8    temp ;</span><br><span class="line">    <span class="keyword">if</span>(usb_running_ctrl_state == USB_IDLE) </span><br><span class="line">	&#123;</span><br><span class="line">        <span class="comment">//bmrequest type one byte</span></span><br><span class="line">        bmRequestType = USB-&gt;rSETUP[<span class="number">0</span>];<span class="comment">//获取setup事务数据包首字节,记录host请求类型</span></span><br><span class="line">        <span class="comment">//brequest one byte</span></span><br><span class="line">        bRequest = USB-&gt;rSETUP[<span class="number">1</span>];</span><br><span class="line">        </span><br><span class="line">	    <span class="comment">//wvalue two bytes</span></span><br><span class="line">        temp = USB-&gt;rSETUP[<span class="number">2</span>];</span><br><span class="line">        wValue = USB-&gt;rSETUP[<span class="number">3</span>];</span><br><span class="line">        wValue = (wValue &lt;&lt; <span class="number">8</span>) + temp;</span><br><span class="line">        </span><br><span class="line">	   <span class="comment">//windex two bytes</span></span><br><span class="line">        temp = USB-&gt;rSETUP[<span class="number">4</span>];</span><br><span class="line">        wIndex = USB-&gt;rSETUP[<span class="number">5</span>];</span><br><span class="line">        wIndex = (wIndex &lt;&lt; <span class="number">8</span>) + temp;</span><br><span class="line">        </span><br><span class="line">	    <span class="comment">//wlength two bytes</span></span><br><span class="line">        temp = USB-&gt;rSETUP[<span class="number">6</span>];</span><br><span class="line">        wLength = USB-&gt;rSETUP[<span class="number">7</span>];</span><br><span class="line">        wLength = (wLength &lt;&lt; <span class="number">8</span>) + temp;</span><br><span class="line">        <span class="comment">//direction</span></span><br><span class="line">        req_dir = bmRequestType &amp; USB_REQ_DIR_MASK ;</span><br><span class="line">        <span class="comment">//recipient</span></span><br><span class="line">        req_recip = bmRequestType &amp; USB_REQ_RECIP_MASK ;</span><br><span class="line">        <span class="comment">//type</span></span><br><span class="line">        req_type = bmRequestType &amp; USB_REQ_TYPE_MASK ;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;bmRequestType = 0x%x\r\n&quot;</span>, bmRequestType);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;bRequest = 0x%x\r\n&quot;</span>, bRequest);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;wValue = 0x%x\r\n&quot;</span>, wValue);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;wIndex = 0x%x\r\n&quot;</span>, wIndex);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;wLength = 0x%x\r\n&quot;</span>, wLength);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;=================================\r\n&quot;</span>);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">        usb_running_ctrl_state = USB_CTRL_SETUP ;</span><br><span class="line">    &#125;</span><br><span class="line">    ctrl_deal_handle();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>usb_setup_handle函数中，会先读取setup事务数据包里面的内容(从第7行开始)，这就涉及到另外一个寄存器：USB 设置包数据寄存器(SETUPX  (X=0~7))</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210427105459.png" style="zoom:67%;">

<p>(同样这个寄存器名字我感觉取的不是特别好，容易引起歧义。更好的说法我觉得是：USB SETUP事务的数据包寄存器。)</p>
<p>​    usb_setup_handle函数中把setup事务的数据包做解析，数据包肯定是有格式约定的，如下表所示：</p>
<table>
<thead>
<tr>
<th><strong>偏移量</strong></th>
<th><strong>请求</strong></th>
<th><strong>大小</strong></th>
<th><strong>意义</strong></th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>bmRequestType</td>
<td>1</td>
<td>请求命令类型。每一位代表一定的意义。<br>D7，选择数据传输方向，0 = 主机到设备（即输出OUT），1 = 设备到主机（即输入IN）。<br>D6D5，命令的类型<br>00 = 标准请求命令<br>01 = 类请求命令<br>10 = 用户定义的请求命令<br>11 = 保留<br>D4-D0，命令的接收者类型<br>00000 = 接收者为设备<br>00001 = 接收者为接口<br>00010 = 接收者为端点<br>00011 = 其他接收者<br>其他值保留。</td>
</tr>
<tr>
<td>1</td>
<td>bRequest</td>
<td>1</td>
<td>请求命令代码。<br>在标准的USB请求命令中，USB为每一个命令定义了编号，即为此段的值。<br>0 = GET_STATUS<br>1 = CLEAR_FEATURE<br>3 = SET_FEATURE<br>5 = SET_ADDRESS<br>6 = GET_DESCRIPTOR<br>7 = SET_DESCRIPTOR<br>8 = GET_CONFIGURATION<br>9 = SET_CONFIGURATION<br>10 = GET_INTERFACE<br>11 = SET_INTERFACE<br>12 = SYNCH_FRAME</td>
</tr>
<tr>
<td>2</td>
<td>wValue</td>
<td>2</td>
<td>命令信息。<br>每一种请求命令都可以自行来定义这个字段的内容。</td>
</tr>
<tr>
<td>4</td>
<td>wIndex</td>
<td>2</td>
<td>索引信息。<br> 命令也可以自定义该字段的内容，但一般该字段的内容为索引值或偏移值。 当传输一个端点的索引值时： <br>第一字节 D7，方向位，0 = 输出OUT端点，1 = 输入IN端点 <br>D3-D0，端点号 <br>其他位即第二字节为保留值0。<br><br>当传输一个接口的索引值时：<br>第一字节<br>D7~D0，接口编号（可以在接口描述符中得到）<br>第二字节为保留值0。</td>
</tr>
<tr>
<td>6</td>
<td>wLength</td>
<td>2</td>
<td>传输的数据大小。<br>该字段表示在控制传输的“可选数据步骤”中要传输的数据大小。<br>当数据发送方向是主机到设备时，字段值便是实际的数据大小；<br>当数据发送方向是设备到主机时，字段值是设备能够发送的最大数据包的大小<br>当然，设备实际发送的数据可以比wLength的值小。</td>
</tr>
</tbody></table>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/***************************************************************************</span></span><br><span class="line"><span class="comment">**函数信息 ：ctrl_deal_handle(void)</span></span><br><span class="line"><span class="comment">**功能描述 ：控制传输数据包及USB状态处理</span></span><br><span class="line"><span class="comment">**输入参数 ：</span></span><br><span class="line"><span class="comment">**输出参数 ：</span></span><br><span class="line"><span class="comment">**备    注 ：记录USB状态方便USB正确响应</span></span><br><span class="line"><span class="comment">****************************************************************************/</span></span><br><span class="line">u8 usb_flag = <span class="number">0</span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">ctrl_deal_handle</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>( req_type == USB_REQ_TYPE_STANDARD )         <span class="comment">// standard request type</span></span><br><span class="line">		&#123;                   </span><br><span class="line">        <span class="keyword">if</span>( bRequest &lt; MAX_STD_REQUEST )            <span class="comment">// handle 0--12</span></span><br><span class="line">				&#123;                      </span><br><span class="line">            (*StandardDeviceRequest[bRequest])( ) ; <span class="comment">// 调用标准请求函数</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>会解析到是个获取设备描述符标准请求，会转到相应的函数去处理：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210427160420.png" style="zoom:77%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210427161355.png" style="zoom:80%;">

<p>这边红框处目的就是设备根据主机数据包中的设备描述符请求做好准备，把要回复给主机的设备描述符准备好。</p>
<h3 id="1-3-setup事务的握手包"><a href="#1-3-setup事务的握手包" class="headerlink" title="1.3 setup事务的握手包"></a>1.3 setup事务的握手包</h3><p>​    设备握手包ACK，代码里面没有直接体现。</p>
<br>

<br>

<h2 id="2-数据过程"><a href="#2-数据过程" class="headerlink" title="2. 数据过程"></a>2. 数据过程</h2><p>​    主机先发一个IN令牌包、设备发一个数据包（这个数据已经准备好，SIE收到IN令牌后，直接送到总线上，用户此时不干预）、主机发ACK包。（SIE 指串行接口引擎，是所有USB控制器内部的‘核心’。SIE 负责处理底层协议，如填充位，CRC生成和校验，并可发出错误报告。SIE的主要任务是将低级信号转换成字节，以供控制器使用）</p>
<h3 id="2-1-IN事务的令牌包"><a href="#2-1-IN事务的令牌包" class="headerlink" title="2.1 IN事务的令牌包"></a>2.1 IN事务的令牌包</h3><p>​    主机发送IN事务的令牌包，MCU的端点接收来自主机的IN包后，如果此时没有足够的数据完成当前传输，USB控制器自动应答NACK包，这个会体现在USB端点0中断状态寄存器里面Bit2位：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210506182948.png" style="zoom:77%;">

<p>程序中就体现在下面截图的第75行：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210506183958.png" style="zoom:80%;">

<p>这边程序刚开始运行的时候，肯定是没准备好数据的，所以会到75行这个分支下面。另外有一点：如果收到 NACK 应答，USB主机会重发IN请求直到该端点确认请求有效。</p>
<p>​    现在进入usb_in_handle()函数继续往下分析，按着流程走走走走，竟然又走到了Chap9_GetDescriptor函数，只是跑的是case USB_CTRL_IN这个分支：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20210509135027.png"></p>
<p>这段代码里涉及到两个比较重要的寄存器EPX_CTRL和EPX_FIFO。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210509140654.png" style="zoom:70%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210509140822.png" style="zoom:70%;">

<p>​        在 USB 设备的端点描述符中包含了端点最大包长（Max Packet Size 即 MPS）信息。USB的端点一次只能传输最大包长的数据，如果数据超出最大包长，将会分成多包进行传输。多包传输时，前面的数据包长度都是最大包长，只有最后一包数据根据实际长度传输。当要完成一次传输时，发送一个数据长度不是最大包长的数据即</p>
<p>可，有这两种情况：a. 如果数据长度不能最大包长整除，最后一包自然会小于最大包长，触发传输完成条件；b. </p>
<p><strong>如果数据长度能被最大包长整除，最一包与最大包长相等，需要再发送一个长度为零的包（Zero Length Packet）来触发传输完成条件</strong>。代码中294行就很好的说明了这一点。发送长度为零的包代码如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210510171243.png" style="zoom:80%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210510152813.png" style="zoom:70%;">

<p>可以总结为下面这样的步骤：</p>
<p>​    1.如果 FIFO 中的数据小于寄存器 EPX_CTRL[6:0] 中设置的大小，或者 EPX_CTRL[7]未设为 1，USB 模块会自动发送 NACK，直到数据准备好。</p>
<p>​    2.CPU 收到 IN_NACK 状态。</p>
<p>​    3.CPU 把数据写入 FIFO。</p>
<p>​    4.CPU 在 EPX_CTRL 寄存器设置待发送的数据大小和发送使能。</p>
<p>​    5.USB 模块在收到下一个 IN 请求的时候自动发送 FIFO 中的数据发送。最后一个数据字节发送完成后，自动发送计算好的 CRC。</p>
<p>​    6.CPU 会收到 IN_ACK 状态，并且在发送结束后收到 END 状态。</p>
<p>​    7.如果端点未使能，或者 EP_HALT 寄存器设置暂停，USB模块会应答IN_STALL而不发送数据。</p>
<h3 id="2-2-IN事务的数据包"><a href="#2-2-IN事务的数据包" class="headerlink" title="2.2 IN事务的数据包"></a>2.2 IN事务的数据包</h3><p>​    体现在上面的步骤5中，设备会给主机返回18字节的设备描述符。</p>
<h3 id="2-3-IN事务的握手包"><a href="#2-3-IN事务的握手包" class="headerlink" title="2.3 IN事务的握手包"></a>2.3 IN事务的握手包</h3><p>​    主机发送ACK包，代码里面没有直接体现。</p>
<br>

<br>

<h2 id="3-状态过程"><a href="#3-状态过程" class="headerlink" title="3. 状态过程"></a>3. 状态过程</h2><p>​    主机发 OUT 包（通知设备要输出）、主机发 0 字节状态数据包（这个是 0字节，表明自己收到设备描述符）、设备发握手 ACK 包。</p>
<p>​    设备接收到主机OUT包的代码应该在如下所示地方：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210512144107.png" style="zoom:67%;">

<p>状态过程的数据包和握手包这边没具体看到有相应的代码，暂时不做具体的分析了。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/04/Jetson%20nano%20i2c/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/04/Jetson%20nano%20i2c/" class="post-title-link" itemprop="url">Jetson nano i2c</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-04 22:35:49" itemprop="dateCreated datePublished" datetime="2021-05-04T22:35:49+08:00">2021-05-04</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/05/04/Jetson%20nano%20i2c/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson nano i2c" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/04/Jetson%20nano%20i2c/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/04/Jetson%20nano%20i2c/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1.简介"></a>1.简介</h2><p>​    先介绍nano板子上的i2c相关的硬件信息：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504213613.png" style="zoom:50%;">

<p>其中用的比较多的是185，187，189，191这两组I2C。</p>
<p>​    我们在jetson nano上执行sudo /opt/nvidia/jetson-io/jetson-io.py，如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504213842.png" style="zoom:67%;">

<p>可以看到这两组I2C默认都是使能的。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504214305.png"></p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504214436.png"></p>
<h2 id="2-I2C-Tools使用"><a href="#2-I2C-Tools使用" class="headerlink" title="2. I2C-Tools使用"></a>2. I2C-Tools使用</h2><p>​    先安装工具：sudo apt-get install -y i2c-tools</p>
<p>​    列出所有I2C总线：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504215145.png" style="zoom:50%;">

<p>​    手上正好有一个MPU6050的模块，我这边准备分别连接到那两个I2C引脚上，看能不能用I2C-Tools检测到我们硬件的地址。</p>
<p>​    <strong>连接方式一</strong>：</p>
<p>​    VCC —接Nano引脚第17脚 </p>
<p>​    GND —接Nano 引脚第25脚 </p>
<p>​    SCL —接Nano 引脚第5脚(GEN2_I2C_SCL) </p>
<p>​    SDA —接Nano 引脚第3脚(GEN2_I2C_SDA)</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504220208.png" style="zoom:80%;">

<p>​    注意：在I2C-1上。</p>
<p>​    <strong>连接方式二</strong>：</p>
<p>​    VCC —接Nano引脚第17脚 </p>
<p>​    GND —接Nano 引脚第25脚 </p>
<p>​    SCL —接Nano 引脚第28脚(GEN1_I2C_SCL) </p>
<p>​    SDA —接Nano 引脚第27脚(GEN1_I2C_SDA)    </p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504220238.png" style="zoom:80%;">

<p>​    注意：在I2C-0上。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/04/Jetson%20Nano%20IO%E7%89%A9%E7%90%86%E5%BC%95%E8%84%9A%E4%B8%8E%E8%99%9A%E6%8B%9F%E5%BC%95%E8%84%9A%E6%98%A0%E5%B0%84%E8%AE%A1%E7%AE%97/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/04/Jetson%20Nano%20IO%E7%89%A9%E7%90%86%E5%BC%95%E8%84%9A%E4%B8%8E%E8%99%9A%E6%8B%9F%E5%BC%95%E8%84%9A%E6%98%A0%E5%B0%84%E8%AE%A1%E7%AE%97/" class="post-title-link" itemprop="url">Jetson Nano IO物理引脚与虚拟引脚映射计算</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-04 11:17:56" itemprop="dateCreated datePublished" datetime="2021-05-04T11:17:56+08:00">2021-05-04</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/05/04/Jetson%20Nano%20IO%E7%89%A9%E7%90%86%E5%BC%95%E8%84%9A%E4%B8%8E%E8%99%9A%E6%8B%9F%E5%BC%95%E8%84%9A%E6%98%A0%E5%B0%84%E8%AE%A1%E7%AE%97/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson Nano IO物理引脚与虚拟引脚映射计算" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/04/Jetson%20Nano%20IO%E7%89%A9%E7%90%86%E5%BC%95%E8%84%9A%E4%B8%8E%E8%99%9A%E6%8B%9F%E5%BC%95%E8%84%9A%E6%98%A0%E5%B0%84%E8%AE%A1%E7%AE%97/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/04/Jetson%20Nano%20IO%E7%89%A9%E7%90%86%E5%BC%95%E8%84%9A%E4%B8%8E%E8%99%9A%E6%8B%9F%E5%BC%95%E8%84%9A%E6%98%A0%E5%B0%84%E8%AE%A1%E7%AE%97/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    说到控制一个GPIO口，马上就能想到写个内核模块，驱动一下，像gpio_request、open、read、write……一堆API就出来了。其实，只是想简单的控制一下GPIO输入或者输出，不用这么复杂，系统已经实现相关驱动了，只需要了解怎么用就可以了。</p>
<p>​    在用户空间通过sysfs控制GPIO，先访问/sys/class/gpio/，向export文件写入<strong>要操作的GPIO编号</strong>，使得该GPIO的操作接口从内核空间暴露到用户空间，GPIO的操作接口包括direction和value等，direction控制GPIO输入或者输出模式，而value可控制GPIO的状态或者读取状态。</p>
<p>​    因此这边如何计算的到上面这个GPIO编号(也叫虚拟引脚)，如果你要操作的那个GPIO比较巧，正好是Jetson nano的40 pin的扩展头里的某一个，并且这个已经帮你计算好了，那就查一下就知道了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504105234.png" style="zoom:67%;">

<p>比如15脚对应的是gpio194，这个194是怎么计算得到的呢？方法如下所示。</p>
<p>​    先进官网，下载如下两个excel文件：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504110108.png" style="zoom:47%;">

<p>《NV_Jetson_Nano_DeveloperKit_Users_Pinmux_Configuration.xlsm》只包含了那40个扩展引脚的说明，《NV_Jetson_Nano_Module_Pinmux_Config_Template.xlsm》包含了芯片所有引脚的说明，在上面这个例子中我们可以只参考前面那个excel。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504110637.png"></p>
<p>​    另外在jetson nano的bsp源码包(《public_sources.tbz2》)里，进入Linux_for_Tegra\source\publickernel_src.tbz2\hardware\nvidia\soc\tegra\kernel-include\dt-bindings\gpio目录。可在该目录下看到《tegra-gpio.h》文件，打开该文件，内容如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * This header provides constants for binding nvidia,tegra*-gpio.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * The first cell in Tegra&#x27;s GPIO specifier is the GPIO ID. The macros below</span></span><br><span class="line"><span class="comment"> * provide names for this.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * The second cell contains standard flag values specified in gpio.h.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> _DT_BINDINGS_GPIO_TEGRA_GPIO_H</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> _DT_BINDINGS_GPIO_TEGRA_GPIO_H</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;dt-bindings/gpio/gpio.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_A 0</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_B 1</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_C 2</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_D 3</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_E 4</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_F 5</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_G 6</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_H 7</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_I 8</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_J 9</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_K 10</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_L 11</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_M 12</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_N 13</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_O 14</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_P 15</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_Q 16</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_R 17</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_S 18</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_T 19</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_U 20</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_V 21</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_W 22</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_X 23</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_Y 24</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_Z 25</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_AA 26</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_BB 27</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_CC 28</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_DD 29</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_EE 30</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO_BANK_ID_FF 31</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> TEGRA_GPIO(bank, offset) \</span></span><br><span class="line">    ((TEGRA_GPIO_BANK_ID_#<span class="meta">#bank * 8) + offset)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<p>《tegra-gpio.h》内容就说明了IO虚拟引脚号公式计算定义。</p>
<p>​    如上图，我们选择的是GPIO12，对应的物理引脚号为：<strong>GPIO3_PY.02</strong>，然后查找到：#define TEGRA_GPIO_BANK_ID_Y 24，代入公式就得到：24*8+2 = 194，所以我们操作的IO虚拟引脚号为194。然后如下图所示，在jetson nano上进行操作，就可以控制那个gpio口了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504111722.png" style="zoom:80%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/04/jetson%20nano%20GPIO%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/04/jetson%20nano%20GPIO%E4%BD%BF%E7%94%A8/" class="post-title-link" itemprop="url">jetson nano GPIO使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-04 09:59:13" itemprop="dateCreated datePublished" datetime="2021-05-04T09:59:13+08:00">2021-05-04</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/05/04/jetson%20nano%20GPIO%E4%BD%BF%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="jetson nano GPIO使用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/04/jetson%20nano%20GPIO%E4%BD%BF%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/04/jetson%20nano%20GPIO%E4%BD%BF%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    Jetson Nano开发板包含一个40引脚GPIO接头，类似于Raspberry Pi中的40引脚接头。可以使用Jetson GPIO Library包中提供的Python库来控制这些GPIO的数字输入和输出。</p>
<p>​    将LED的正极接在Jetson Nano的第15引脚上，负极接在第39引脚（GND）上，通过控制引脚输出高低电平，控制LED的亮灭。</p>
<p>​    Jetson.GPIO的GPIO的设置有四种模式，模式不同同一引脚的名称就不一样。这里介绍其中两种：</p>
<p>​    (1).BOARD（the pin number of the 40 pin GPIO header）：就是引脚序号，也就是第一个图红框里边的引脚号，和丝印标注的序号是一致的。</p>
<p>​    (2).BCM（the Broadcom SoC GPIO numbers）：就是芯片的引脚编号。芯片的引脚编号是芯片未焊接时的从初始引脚标注起周围一圈引脚的编号。</p>
<p>​    物理管脚BOARD编码和Jetson Nano上的管脚是正好一一对应的，是物理关系，手册中写为GPIO Header。但BCM中就不是物理数值关系对应了，BCM是根据博通SoC的GPIO规则命名的。BOARD编码中的15号管脚，在BCM 中的编码就是22号管脚。在Jetson Nano正面写的是Board编码，反面写的是相应的BCM编码，可以留心查看。</p>
<p>​    下面直接上代码：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504095338.png" style="zoom:70%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504095423.png" style="zoom:70%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210504095554.jpg" style="zoom:30%;">


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/03/EC20%20R2.1%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%ABSIM%E5%8D%A1%E6%8E%92%E6%9F%A5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/03/EC20%20R2.1%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%ABSIM%E5%8D%A1%E6%8E%92%E6%9F%A5/" class="post-title-link" itemprop="url">EC20 R2.1无法识别SIM卡排查</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-03 16:31:46" itemprop="dateCreated datePublished" datetime="2021-05-03T16:31:46+08:00">2021-05-03</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2021/05/03/EC20%20R2.1%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%ABSIM%E5%8D%A1%E6%8E%92%E6%9F%A5/" class="post-meta-item leancloud_visitors" data-flag-title="EC20 R2.1无法识别SIM卡排查" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/03/EC20%20R2.1%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%ABSIM%E5%8D%A1%E6%8E%92%E6%9F%A5/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/03/EC20%20R2.1%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%ABSIM%E5%8D%A1%E6%8E%92%E6%9F%A5/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    这几天在调试移远的EC20 4G模块，驱动和工具都已经移植到了jetson nano上，但是运行quectel工具来连接网络的时候，发现出下面的log，主要的意思就是没有识别sim卡。 </p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210501225930.png" style="zoom:60%;">

<p>​     移远的FAE建议我先用AT读下卡的状态，用AT+CPIN？,我执行后返回+CME ERROR: 10确实是有问题。</p>
<p>​     先按照移远的文档《SIM卡无法识别排查解决方案》来一点点排查，我测试了模块SIM卡接口相关引脚阻抗（SIM_VDD、SIM_DATA、SIM_CLK、SIM_RST）,以 EC20模组为例，引脚对地阻抗为 0.4~0.6V（不同模组的引脚阻抗不尽相同，SIM_DATA、SIM_CLK&amp;SIM_RST 阻抗值相近，SIM_VDD 阻抗值略大）</p>
<p>​    引脚阻抗测量方法如下(<strong>测量的时候模块不需要上电</strong>)：</p>
<p>​    使用万用表二极管档位，红表笔接 GND，黑表笔接所需测的模块引脚。如下图：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503160957.png" style="zoom:50%;">

<p>​    好像一切都正常，哎，烦噪。继续排查，这次用示波器测量模块每个引脚的波形，看模块是是否存在识卡的动作(这个<strong>不需要把那个quectel-Cm运行起来，只要模组上电就可以了</strong>)。移远的文档中也提到了：模组 SIM_VDD 和 SIM_RESE 电平由 1.8V 切换至 3.0V,后变为低电平。其实模组想法是：我先去找你1.8V的SIM卡；我找不到我再找你3.0V的SIM的卡，我要是再找不到你就不能怪我了，我可就关闭电源了哦。而不是我们大多数人认为你的SIM_VDD为啥没电了，所以导致我不识卡了。</p>
<p>​    当然文档中还提到了其他几个引脚正确的波形样子，我这里偷懒只量了一个SIM_VDD引脚，我把模块断电后再上电，观察该引脚的波形，如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20210503161645.jpg" style="zoom:37%;">

<p>模块确实有去识卡的动作，但是最后没识别到恢复成0V。</p>
<p>​    哎，到底是什么原因？继续看它的文档，文档总体意思是先怀疑模块正常不，模块我感觉大概率是正常的，那最后就是怀疑卡座有没有问题。文档中提到：如果你测试模块 SIM_VDD、SIM_DATA、SIM_CLK、SIM_RST 都具有识卡动作，说明模组是正常的，建议此时断开调试电阻，飞一个 SIM 卡直接连接模块引脚，排查是否是 SIM 卡座导致不识卡。SIM 卡座是通过弹片接触 SIM 卡，弹片容易氧化，或与 SIM 卡接触不良导致不识卡。但是我的卡座是新的，不太可能是弹片氧化吧，突然看到文档中第一点，会不会是卡插反了。但是卡插进去的时候 也可以吧嗒一下固定，根本没怀疑插反。我抱着试试看的心态再仔细看了一下那卡座，卧槽卧槽卧槽，上面有一个卡的图形，告诉我们怎么个方向插卡，尼玛，我确实插反了。。。。。。然后问题解决了。。。。。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20210503163019.jpg" style="zoom:37%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/03/EC20%20mini%20PCIe-C%E6%8E%A5%E5%8F%A3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/03/EC20%20mini%20PCIe-C%E6%8E%A5%E5%8F%A3/" class="post-title-link" itemprop="url">EC20 mini PCIe-C接口</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-03 15:59:43" itemprop="dateCreated datePublished" datetime="2021-05-03T15:59:43+08:00">2021-05-03</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2021/05/03/EC20%20mini%20PCIe-C%E6%8E%A5%E5%8F%A3/" class="post-meta-item leancloud_visitors" data-flag-title="EC20 mini PCIe-C接口" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/03/EC20%20mini%20PCIe-C%E6%8E%A5%E5%8F%A3/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/03/EC20%20mini%20PCIe-C%E6%8E%A5%E5%8F%A3/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    这几天在调试移远的EC20 4G模块，选的这款型号是：EC20 R2.1 Mini PCIe-C模块接口的，如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20210503154817.jpg" style="zoom:37%;">

<p>在手册《Quectel_EC20_R2.1_Mini_PCIe-C(Audio版本)_硬件设计手册_V1.0》中有介绍PCIe-C 模块接口引脚分配，其中贴有 EC20 R2.1 模块和天线连接器为TOP 面，反面为 BOT 面。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503155153.png" style="zoom:70%;">

<p>​    其中我用红色框出来的几个引脚，是(U)SIM接口，它是和sim卡有关系的。EC20 R2.1 Mini PCIe-C 模块的(U)SIM 接口符合 ETSI 和 IMT-2000 规范，支持 1.8V 和 3.0V 工作电压。引脚定义如下表所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503155719.png" style="zoom:57%;">

<p>​    通过 USIM_PRESENCE 引脚，EC20 R2.1 Mini PCIe-C 模块可支持(U)SIM 卡热插拔功能，并且支持</p>
<p>低电平和高电平检测。该功能默认关闭。详情请参考<strong>AT+QSIMDET</strong> 命令。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/05/03/nano%20sim%E5%8D%A1%E5%92%8Cmicro%20sim%E5%8D%A1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/05/03/nano%20sim%E5%8D%A1%E5%92%8Cmicro%20sim%E5%8D%A1/" class="post-title-link" itemprop="url">nano sim卡和micro sim卡</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-05-03 15:38:06" itemprop="dateCreated datePublished" datetime="2021-05-03T15:38:06+08:00">2021-05-03</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2021/05/03/nano%20sim%E5%8D%A1%E5%92%8Cmicro%20sim%E5%8D%A1/" class="post-meta-item leancloud_visitors" data-flag-title="nano sim卡和micro sim卡" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/05/03/nano%20sim%E5%8D%A1%E5%92%8Cmicro%20sim%E5%8D%A1/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/05/03/nano%20sim%E5%8D%A1%E5%92%8Cmicro%20sim%E5%8D%A1/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    这几天在调试移远的EC20 4G模块，上面需要插入micro sim卡(sim卡还不止这一种，真是日了狗了。。。)，因此这边总结一下nano sim卡和micro sim卡的区别。资料来源于网上，参考链接如下所示：</p>
<p><a target="_blank" rel="noopener" href="http://blog.sina.com.cn/s/blog_18e78d69d0102z41u.html">http://blog.sina.com.cn/s/blog_18e78d69d0102z41u.html</a></p>
<p><a target="_blank" rel="noopener" href="https://jingyan.baidu.com/article/219f4bf7ba552dde442d3886.html">https://jingyan.baidu.com/article/219f4bf7ba552dde442d3886.html</a></p>
<p><a target="_blank" rel="noopener" href="https://wenku.baidu.com/view/7e38f77dfad6195f302ba635.html">https://wenku.baidu.com/view/7e38f77dfad6195f302ba635.html</a></p>
<h2 id="1-卡"><a href="#1-卡" class="headerlink" title="1. 卡"></a>1. 卡</h2><p>​    NANO SIM卡和MICRO SIM卡其实用处都是一样的，主要就是表现在大小不一样上。micro sim卡是将标准sim卡剪小，而nano sim卡是将micro sim卡进一步剪小。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503152450.png" style="zoom:53%;">

<p>标准SIM卡的尺寸为25mm×15mm，Micro SIM卡尺寸是12×15mm，Nano SIM卡，尺寸为 12mm x 9mm。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503152641.png" style="zoom:50%;">

<h2 id="2-卡座"><a href="#2-卡座" class="headerlink" title="2. 卡座"></a>2. 卡座</h2><p>​    我这边用的是micro sim卡，因此这里就介绍一下micro sim卡座。</p>
<p>​    MICRO SIM卡座分为自弹式和掀盖式，属于中型体积的SIM卡，其中SIM卡座有分带不带检测脚，自弹式的多使用于外部插卡方式，优势是插卡使用起来较为方便，掀盖式的多适用于产品内部，优势在于不会因为振动或者撞击而导致退卡即而接触不到。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503153237.png" style="zoom:50%;">

<p>​    卡座各引脚的定义可以参考下图，很直观：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503153554.png" style="zoom:77%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210503153655.png" style="zoom:80%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/04/30/jetson%20nano%E5%AE%9E%E7%8E%B0%E7%AE%80%E5%8D%95hello%20world%E9%A9%B1%E5%8A%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/04/30/jetson%20nano%E5%AE%9E%E7%8E%B0%E7%AE%80%E5%8D%95hello%20world%E9%A9%B1%E5%8A%A8/" class="post-title-link" itemprop="url">jetson nano实现简单hello world驱动</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-04-30 22:27:47" itemprop="dateCreated datePublished" datetime="2021-04-30T22:27:47+08:00">2021-04-30</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jetson/" itemprop="url" rel="index"><span itemprop="name">Jetson</span></a>
                </span>
            </span>

          
            <span id="/2021/04/30/jetson%20nano%E5%AE%9E%E7%8E%B0%E7%AE%80%E5%8D%95hello%20world%E9%A9%B1%E5%8A%A8/" class="post-meta-item leancloud_visitors" data-flag-title="jetson nano实现简单hello world驱动" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/04/30/jetson%20nano%E5%AE%9E%E7%8E%B0%E7%AE%80%E5%8D%95hello%20world%E9%A9%B1%E5%8A%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/04/30/jetson%20nano%E5%AE%9E%E7%8E%B0%E7%AE%80%E5%8D%95hello%20world%E9%A9%B1%E5%8A%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    这边演示一下如何在jetson nano上完成一个简单的hello world驱动，驱动的话需要用到kernal源码，这个在《jetson nano L4T kernel编译》这篇博文里面已经有介绍怎么去下载源码并且编译源码，只不过那边编译过程的时候稍微复杂化了一点，这篇博文里面索性用更简单的方式。</p>
<h2 id="1-编译kernal源码"><a href="#1-编译kernal源码" class="headerlink" title="1. 编译kernal源码"></a>1. 编译kernal源码</h2><p>​    实现驱动的第一步先需要编译kernal源码，如果没有编译内核源码，而是直接编译驱动代码的话，会报下面这样的错误：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210430214827.png" style="zoom:67%;">

<p>​    因此需要先编译kernel，编译的时候需要设置目标板架构ARCH 和交叉编译器 CROSS_COMPILE，</p>
<p>在顶层Makefile中修改代码如下：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210430215657.png" style="zoom:67%;">

<p>然后执行下面这些指令就编译成功了：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo make tegra_defconfig</span><br><span class="line">make -j4</span><br></pre></td></tr></table></figure>
<h2 id="2-写hello-world驱动"><a href="#2-写hello-world驱动" class="headerlink" title="2. 写hello world驱动"></a>2. 写hello world驱动</h2><p>​    这边直接上hello.c文件中的代码：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;linux/init.h&gt;  </span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;linux/module.h&gt;  </span></span></span><br><span class="line">MODULE_LICENSE(<span class="string">&quot;Dual BSD/GPL&quot;</span>);  </span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">int</span> <span class="title">hello_init</span><span class="params">(<span class="keyword">void</span>)</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    printk(KERN_ALERT <span class="string">&quot;Hello, world\n&quot;</span>);  </span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;  </span><br><span class="line">&#125;  </span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">hello_exit</span><span class="params">(<span class="keyword">void</span>)</span>  </span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    printk(KERN_ALERT <span class="string">&quot;Goodbye, cruel world\n&quot;</span>);  </span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;  </span><br><span class="line">&#125;  </span><br><span class="line"></span><br><span class="line">module_init(hello_init);  </span><br><span class="line">module_exit(hello_exit);</span><br></pre></td></tr></table></figure>
<p>​    另外还需要写Makefile文件，内容如下：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">KERNELDIR=/home/xdl/WorkSpace/nano_kernel_source/Linux_for_Tegra/source/public/kernel_src/kernel/kernel-4.9    </span><br><span class="line"></span><br><span class="line">CURRENT_PATH := <span class="variable">$(<span class="built_in">shell</span> pwd)</span>   </span><br><span class="line">obj-m := hello.o</span><br><span class="line"><span class="section">build: kernel_modules  </span></span><br><span class="line"><span class="section">kernel_modules:     </span></span><br><span class="line">	<span class="variable">$(MAKE)</span> -C <span class="variable">$(KERNELDIR)</span> M=<span class="variable">$(CURRENT_PATH)</span> modules     </span><br><span class="line"><span class="section">clean:     </span></span><br><span class="line">	<span class="variable">$(MAKE)</span> -C <span class="variable">$(KERNELDIR)</span> M=<span class="variable">$(CURRENT_PATH)</span> clean  </span><br></pre></td></tr></table></figure>
<p>​    然后直接执行make，就可以生成hello.ko驱动。</p>
<h2 id="3-验证驱动"><a href="#3-验证驱动" class="headerlink" title="3. 验证驱动"></a>3. 验证驱动</h2><p>​    把这个文件拷贝到jetson nano上，执行: sudo insmod hello.ko，但是没有打印任何东西出来，我这边用dmesg，就可以看到打印的Hello,world。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210430222507.png"></p>
<p>​    同时执行：lsmod，也可以看到hello这个驱动。</p>
<p>​    执行：sudo rmmod hello，可以删除这个驱动。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/22/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/22/">22</a><span class="page-number current">23</span><a class="page-number" href="/page/24/">24</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/24/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
